home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / science / sm32a.zip / SYMBMATH.H48 < prev    next >
Text File  |  1994-12-22  |  5KB  |  125 lines

  1.         5.   Graphics
  2.     SymbMath includes extensive facilities for graphing. It supports
  3. BGI-graphics, which graphics commands are the same as those in Borland 
  4. Turbo Pascal and Turbo C, except for:
  5.  
  6.           different graphics commands
  7. ------------------------------------------------
  8. SymbMath             Turbo Pascal or C
  9.  
  10. graph                initgraph(drive,mode,path)
  11. text                 closegraph
  12. writes(x)            outtext(x)
  13. -------------------------------------------------
  14.                                         
  15.     Before graphing (drawing or plotting), you must initialize the 
  16. graphics system and puts the computer hardware into graphics mode by 
  17. the command:
  18.         graph
  19.  
  20.         5.1  Drawing lines and arcs
  21. then you can draw a line by
  22.         line(x1,y1,x2,y2)
  23.         lineto(x2,y2)
  24.         linerel(dx,dy)
  25. draw a circular arc by                
  26.         arc(x,y,angle1,angle2,radius)
  27. draw an elliptical arc by                
  28.         ellipse(x,y,angle1,angle2,XRadius,YRadius)
  29. put a pixel by                
  30.         putpixel(x,y,color)
  31.     you can move a pointer by
  32.         moveto(x,y)
  33.         moverel(dx,dy)
  34.         A upper left corner on your graphics screen coordinates is (0,0).
  35.         The color and style of the line can be set by setcolor() and
  36. setlinestyle(). You can set screen colors.
  37.      If you are using a color system, you can set the color of the next
  38. line or graph or text with the command:
  39.                  setcolor(color)
  40. where color is an integer in the range 0..15, or one of the color words if
  41. package color.sm has been loaded.
  42.      You can set the background color for your graphs with the command
  43.         setbkcolor(color)
  44. where color is color number (i.e. an integer in the range 0..15), or one 
  45. of the colorno(x) function value.
  46.  
  47.         Table 5.1     ColorNo(x) function in the colorno.li library
  48. ------------------------------------------------------------------
  49. x                    value
  50.  
  51. black                     0
  52. blue                      1
  53. green                     2
  54. cyan                      3
  55. red                       4
  56. magenta                   5
  57. brown                     6
  58. lightgray                 7
  59. gray                      8
  60. lightblue                 9
  61. lightgreen                10
  62. lightcyan                 11
  63. lightred                  12
  64. lightmagenta              13
  65. yellow                    14
  66. white                     15
  67. ----------------------------------------
  68.  
  69.      You can set line styles.
  70.      On both monochrome and color systems, you can draw lines and graphs
  71. with different line styles.  (Since the line segments used to draw graphs
  72. are usually very short, different line styles may not be distinguished in
  73. graphs, but they will be distinguished on long lines.)  Linestyles are
  74. indicated by integers in the range 0..3, and are set by the command:
  75.                 setlinestyle(style,u,thickness)
  76. where style, u and thickness are integers.
  77.     You can set the text style by
  78.         settextstyle(font,direction,size)
  79. where font, direction and size are integers.
  80.         You can add labels to your graphs by
  81.                 writes(s)
  82.      You can put alphanumeric labels anywhere on your graphic screens.
  83. They can be horizontal or vertical, and they can be printed in various
  84. sizes. To print a string  s  horizontally on the screen with the
  85. lower-left corner at the screen coordinates (x,y), use two commands:
  86.                 moveto(x,y), writes(s)
  87. To write vertically bottom to top, use two commands:
  88.                 settextstyle(1,2,2), writes(s)
  89.       
  90.       If SymbMath attempts to graph a point (x,y) which is outside the
  91. the screen coordinate, it ignores the point and continues.  No error
  92. message is generated, and even functions which are undefined on part of
  93. the graphing domain can be graphed.
  94.           You can get the max x and max y on your graphics screen
  95. coordinates by
  96.                 getmaxx
  97.                 getmaxy
  98.           You can get the current point(x, y) on your graphics screen
  99. coordinates by
  100.                 getx
  101.                 gety
  102.           You can get the background color and foregroud color on your
  103. graphics screen by
  104.                 getbkcolor
  105.                 getcolor
  106.           You can read a character from the keyboard or pause by the
  107. command:
  108.         readchar
  109.       You can clear graph by
  110.         cleardevice
  111.  
  112.       SymbMath auto goes back the text mode at the end of run. You 
  113. can force it goes back the text mode by the command:
  114.                 text
  115.  
  116.       Example 5.1:      
  117. #    drawing a group of circles and ovals.
  118. #    Circles are 9 planets around sun.
  119.  
  120. graph                                        # graph mode
  121. do(circle(getmaxx*0.5+2.5*x,getmaxy*0.5,5), x,0,90,10)
  122. do(oval(getmaxx*0.5,getmaxy*0.5,2.5*x,x), x,10,90,10)
  123. readchar                                     # pause graph by read a char
  124. text                                         # back text mode
  125.